From: Ori Livneh Date: Thu, 19 Dec 2013 07:14:10 +0000 (-0800) Subject: Fix round-off error in Vector's collapsibleTabs.js X-Git-Tag: 1.31.0-rc.0~17576^2 X-Git-Url: http://git.cyclocoop.org/%28%5B%5E/404?a=commitdiff_plain;h=1a09f15671f91826d33421a12decd2c4b40906af;p=lhc%2Fweb%2Fwiklou.git Fix round-off error in Vector's collapsibleTabs.js Values returned by jQuery's .width() are rounded off, whereas offset values computed with .offset() are not. As a result, if the window is sized just right, collapsibleTabs.js will decide it has enough room to expand a tab when it really doesn't. It will then detect the tab overlap caused by squeezing in an additional tab and collapse it. It gets stuck in an infinite loop doing that. We could replace usage of $(el).width() with el.getBoundingClientRect().width and thereby make the width calculations precise, but I noticed that jQuery is nervous enough about the availability of getBoundingClientRect that it includes a check to make sure it is not undefined. Rather than run the risk of a ReferenceError, we can simply require an additional extra pixel of space before we decide to expand anything. Bug: 58682 Change-Id: Ib2096894619b8343735de482ee8bfa20a7cd0f48 --- diff --git a/skins/vector/collapsibleTabs.js b/skins/vector/collapsibleTabs.js index 83d043e6b9..e33cfc9560 100644 --- a/skins/vector/collapsibleTabs.js +++ b/skins/vector/collapsibleTabs.js @@ -72,8 +72,10 @@ collapsible: 'li.collapsible', shifting: false, expandCondition: function ( eleWidth ) { - // If there's at least eleWidth pixels free space, expand. - return calculateTabDistance() >= eleWidth; + // If there are at least eleWidth + 1 pixels of free space, expand. + // We add 1 because .width() will truncate fractional values + // but .offset() will not. + return calculateTabDistance() >= (eleWidth + 1); }, collapseCondition: function () { // If there's an overlap, collapse.